package result

import (
	"time"
)

type ResponseSuccessBean struct {
	Code       uint32      `json:"code"`
	Message    string      `json:"message"`
	Result     interface{} `json:"result"`
	ReturnData interface{} `json:"returnData"`
	Success    bool        `json:"success"`
	Timestamp  int64       `json:"timestamp"`
}
type ResponseSuccessBean2 struct {
	Code string      `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type ResponseErrorBean struct {
	Code    uint32 `json:"code"`
	Message string `json:"message"`
}
type ResponseErrorBean2 struct {
	Code    string `json:"code"`
	Message string `json:"msg"`
}

var Res ResponseSuccessBean

func Success(data interface{}) *ResponseSuccessBean {
	if Res.Message == "" {
		Res.Message = "操作成功!"
	}

	return &ResponseSuccessBean{
		Code:       200,
		Message:    Res.Message,
		Result:     data,
		ReturnData: nil,
		Success:    true,
		Timestamp:  time.Now().Unix(),
	}
}

//	func Success(data interface{}) *ResponseSuccessBean2 {
//		if Res.Message == "" {
//			Res.Message = "操作成功!"
//		}
//
//		return &ResponseSuccessBean2{
//			Code: "200",
//			Msg:  Res.Message,
//			Data: data,
//		}
//	}
//
//	func Error(errCode uint32, errMsg string) *ResponseErrorBean2 {
//		return &ResponseErrorBean2{strconv.Itoa(int(errCode)), errMsg}
//	}
func Error(errCode uint32, errMsg string) *ResponseErrorBean {
	return &ResponseErrorBean{errCode, errMsg}
}
